using System.Collections.Generic;
using System.Reflection;

namespace Kopernikus.Parsing.GenericActions
{
    public class DefaultLexerAction<TLexer, TToken> : LexerAction<TLexer, TToken>
    {
        public DefaultLexerAction(MethodInfo methodInfo) : base(methodInfo, null)
        {
        }

        protected override Symbol MapSymbol(string value, Dictionary<string, Symbol> symbolCache)
        {
            Symbol s;
            if (!symbolCache.TryGetValue(value, out s))
            {
                s = new Symbol(value);
                symbolCache.Add(value, s);
            }
            return s;
        }
    }
}